package service

import "golang.org/x/time/rate"

type Config struct {
	App struct {
		Name        string `mapstructure:"name"`
		Port        int    `mapstructure:"port"`
		Domain      string `mapstructure:"domain"`
		UseTemplate string `mapstructure:"useTemplate"`
		SslForce    bool   `mapstructure:"sslForce"`
		SslPort     int    `mapstructure:"sslPort"`
		SslCrt      string `mapstructure:"sslCrt"`
		SslKey      string `mapstructure:"sslKey"`
		Token       struct {
			Secret         string `mapstructure:"secret"`
			Issue          string `mapstructure:"issue"`
			ExpirationTime int    `mapstructure:"expiration_time"`
		} `mapstructure:"token"`
		Env string
	} `mapstructure:"app"`
	Log struct {
		Use      string `mapstructure:"use"`
		Path     string `mapstructure:"path"`
		Request  bool   `mapstructure:"request"`
		Response bool   `mapstructure:"response"`
		Logstash struct {
			Addr string `mapstructure:"addr"`
			Port string `mapstructure:"port"`
		} `mapstructure:"logstash"`
	} `mapstructure:"log"`
	Db struct {
		Use    string `mapstructure:"use"`
		Dsn    string `mapstructure:"dsn"`
		Sqlite struct {
			Path string `mapstructure:"path"`
			Name string `mapstructure:"name"`
		} `mapstructure:"sqlite"`

		Mysql struct {
			Ip       string `mapstructure:"ip"`
			Port     int    `mapstructure:"port"`
			User     string `mapstructure:"user"`
			Pass     string `mapstructure:"pass"`
			Db       string `mapstructure:"db"`
			Timeout  int    `mapstructure:"timeout"`
			ConnMax  int    `mapstructure:"connMax"`
			ConnOpen int    `mapstructure:"connOpen"`
		} `mapstructure:"mysql"`
	} `mapstructure:"db"`

	Cache struct {
		Use    string `mapstructure:"use"`
		Memory int    `mapstructure:"memory"`
	}

	Redis struct {
		Enable   bool   `mapstructure:"enable"`
		Addr     string `mapstructure:"addr"`
		Password string `mapstructure:"password"`
		Timeout  int    `mapstructure:"timeout"`
		DB       int    `mapstructure:"db"`
	} `mapstructure:"redis"`
	Mail struct {
		User     string `mapstructure:"user"`
		Password string `mapstructure:"password"`
		Host     string `mapstructure:"host"`
		Port     int    `mapstructure:"port"`
		SSL      bool   `mapstructure:"ssl"`
	} `mapstructure:"mail"`
	Limit struct {
		Enable    bool       `mapstructure:"enable"`
		RateLimit rate.Limit `mapstructure:"rate_limit"`
		RateTotal int        `mapstructure:"rate_total"`
	} `mapstructure:"limit"`
	Security struct {
		Enable bool `mapstructure:"enable"`
		Login  struct {
			Retry    int `mapstructure:"retry"`
			MaxRetry int `mapstructure:"max_retry"`
		} `mapstructure:"login"`
	} `mapstructure:"security"`
	Feishu struct {
		Bot struct {
			TestBot string `mapstructure:"test_bot"`
		} `mapstructure:"bot"`
	} `mapstructure:"feishu"`
	OpenapiKey string `mapstructure:"openapiKey"`
}
